package com.woniuxy.config;

import org.springframework.amqp.core.CustomExchange;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: wanghao
 * @Date: 2019/9/11 14:53
 */
@Configuration
public class ExchangeConfig {

    /**
     * 延时队列交换机
     * 注意这里的交换机类型：CustomExchange
     * @return
     */
    @Bean
    public CustomExchange delayExchange(){
        Map<String, Object> args = new HashMap<>(1);
        args.put("x-delayed-type", "direct");
        return new CustomExchange(RabbitMqConfig.EXCHANGE_DELAYED,"x-delayed-message",true, false,args);
    }


}
